import request from "@/utils/request"

export default {
  getAdminList(data) {
    return request({
      url: "/admin/list",
      method: "get",
      params: {
        pageNo: data.pageNo,
        pageSize: data.pageSize,
      },
    });
  },

  updateAdmin(data) {
    return request({
      url: "/admin/update",
      method: "put",
      data: data.user
    });
  },

  delAdmin(data) {
    const id = data.id;
    const url = "/admin/delete/" + id;
    console.log(data.id);
    return request({
      url: url,
      method: "delete",
    });
  },

  addAdmin(data) {
    return request({
      url: "/admin/add",
      method: "post",
      data: data.admin,
    });
  },

  getAssignRoleList(data) {
    return request({
      url: "/admin/getRoleListForAssign",
      method: "get",
      params: {
        pageNo: data.pageNo,
        pageSize: data.pageSize,
      },
    });
  },

  getRoleIdByUserId(data) {
    const id = data.id;
    return request({
      url: "/admin/getRoleByUserId/" + id,
      method: "get",
    });
  },

  saveUserRole(data) {
    return request({
      url: "/admin/saveUserRole",

      method: "post",
      headers: {
        'Content-Type':"application/json"
      },
      data
    });
  },
};
